<template>
	<view class="assemblyOrder-container">
		<view class="dome pt20 pb50 pl20 pr20 ">
			<view class="flex mb10">
				<view class="w200">
					生产单号:
				</view>
				<view class="w480" style="word-break: break-word;">
					{{ info.bomProductionCode || '' }}
				</view>
			</view>

			<view class="flex mb10">
				<view class="w200">
					制单日期:
				</view>
				<view class="w480" style="word-break: break-word;">
					{{ info.createTime || '' }}
				</view>
			</view>

			<view class="flex mb10">
				<view class="w200">
					交货日期:
				</view>
				<view class="w480" style="word-break: break-word;">
					{{ info.deliveryDate || '' }}
				</view>
			</view>

			<view class="flex mb10">
				<view class="w200">
					产品名称:
				</view>
				<view class="w480" style="word-break: break-word;">
					{{ info.productName || '' }}
				</view>
			</view>

			<view class="flex mb10">
				<view class="w200">
					生产数量:
				</view>
				<view class="w480" style="word-break: break-word;">
					{{ info.produceNumber || '' }}
				</view>
			</view>

			<view class="flex mb10">
				<view class="w200">
					备注:
				</view>
				<view class="w480" style="word-break: break-word;">
					{{ info.remark || '' }}
				</view>
			</view>
		</view>


		<view class="footer">
			<view class="flex" style="padding: 0 50rpx;">
				<u-button @click="handleAssemblyInformation" type="success" text="录入组装信息"></u-button>
				<view class="ml20 mr20"></view>
				<u-button @click="handlePackaging" type="error" text="录入包装信息"></u-button>
			</view>

			<!-- 
			<view class="text">
				该订单还未进入到您所属的工序中，暂时无法进行操作
			</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: '',
				ids: '',
				info: {}
			}
		},
		onLoad(e) {
			this.type = e.type
			this.ids = e.id
		},
		onShow() {
			this.handleInfo()
		},
		methods: {
			// 获取相信信息
			async handleInfo() {
				try {
					const {
						data
					} = await this.$api.getDetails(this.ids)

					this.info = data
				} catch (error) {
					//TODO handle the exception
					console.log(error, '报错')
				}
			},
			/** 跳转录入组装信息 */
			async handleAssemblyInformation() {

				const {
					data
				} = await this.$api.getCheckPermissions({
					orderOperation: 1,
					processNumber: 1,
					semiFlag: 0
				})


				if (data == 1) {
					if (this.info.commonParts == 2) {
						this.ToPage(
							`/pagesIndex/enterAssemblyInformation/enterAssemblyInformation?id=${this.info.id}&bomId=${this.info.bomId}&type=1`
							)
					} else {
						this.$msg.error('请先完成配料')
					}
				} else {
					this.$msg.error('您没有此权限')
				}
			},
			async handlePackaging() {

				const {
					data
				} = await this.$api.getCheckPermissions({
					orderOperation: 1,
					processNumber: 2,
					semiFlag: 0
				})

				if (data == 1) {


					if (this.info.productAssembly == 0 || this.info.productAssembly == null) return this.$msg.error(
						'请先开始成品组装')
					this.ToPage(
						`/pagesIndex/enterAssemblyInformation/enterAssemblyInformation?id=${this.info.id}&bomId=${this.info.bomId}&type=2`
						)
				} else {
					this.$msg.error('您没有此权限')
				}
			},
		}
	}
</script>

<style scoped lang="scss">
	.assemblyOrder-container {
		width: 100%;
		min-height: 100vh;
		background-color: #F5F5F5;

		.dome {
			background-color: #FFFFFF;
			border-radius: 8rpx;
			margin: 10rpx auto;
			width: 710rpx;
			border: 1rpx solid #C8C8C8;
		}


		.footer {
			position: fixed;
			bottom: 0;
			left: 0;
			width: 750rpx;
			padding-bottom: 150rpx;

			.text {
				width: 100%;
				text-align: center;
				color: #F76C5F;
				font-size: 26rpx;
			}
		}
	}
</style>